Những câu hỏi liên quan
Gà Công Nghệ
Xem chi tiết
Anh Phạm
28 tháng 8 2021 lúc 19:43

uses crt;

var n,i,o,d:integer;

function ktnt(n:integer): integer;

var i,d:integer;

begin

d:=0;

for i:=1 to sqrt(n) do

if (n mod i=0) then d:=d+1;

if d=2 then ktnt=0

else ktnt=1;

end;

begin

readln(n);

writeln(' so nguyen to be hon hoac bang n la'); {a}

for i:=1 to n do

if ktnt(i)=0 then writeln(i);

writeln('so nguyen to nho nhat khong be hon n');

o:=n;

while o>0 do

begin

if ktnt(o)=0 then

begin

write(o);

break;

end;

o:=o+1;

end;

writeln('cặp số nguyên tố là hai số nguyên lẻ liên tiếp nhỏ hơn hoặc bằng n');

o:=0;

o:=1;

d:=0;

for i:=o+2 to n do

begin

if ktnt(i)=0 then

begin

d:=d+1;

write(i,' ');

if d<2 then continue;

end;

d:=0;

writeln;

end;

readln;

end.

Bình luận (1)
Phan Đức Duy
Xem chi tiết
hacker
10 tháng 1 2021 lúc 17:31

uses crt;var n: longint;    chrn: string;    valn,sum,max,i,preperror: byte;begin    write('Nhap so can kiem tra: ');    readln(n);    str(n,chrn);    for i:=1 to length(chrn) do    begin        val(chrn[i],valn,preperror);        sum:=sum+valn;        if max<valn then max:=valn;        valn:=0    end;    writeln('Ket qua: ');    writeln(length(chrn));    writeln(sum);    write(max);    readln;end.uses crt;var n: longint;    chrn: string;    valn,sum,max,i,preperror: byte;begin    write('Nhap so can kiem tra: ');    readln(n);    str(n,chrn);    for i:=1 to length(chrn) do    begin        val(chrn[i],valn,preperror);        sum:=sum+valn;        if max<valn then max:=valn;        valn:=0    end;    writeln('Ket qua: ');    writeln(length(chrn));    writeln(sum);    write(max);    readln;end.

Bình luận (0)
Minh Lệ
10 tháng 1 2021 lúc 20:09

Program HOC24;

var N:longint;

max,tg,t,d: integer;

Begin

write('Nhap N : '); readln(N);

max:=0;

while n<>0 do

begin

tg:=n mod 10;

d:=d+1;

t:=t+tg;

if tg>max then max:=tg;

n:=n div 10;

end;

writeln('So nguyen N co ',d,' chu so');

writeln('Tong cac chu so cua N la : ',t);

write('Chu so lon nhat cua N la :',max);

readln

end.

Bình luận (0)
Nguyễn Lê Phước Thịnh
10 tháng 1 2021 lúc 20:11

uses crt;

var n,d,i,t,max,x:longint;

y:integer;

st:string;

begin

clrscr;

repeat

write('Nhap n='); readln(n);

until n>0;

str(n,st);

d:=length(st);

writeln('So chu so cua ',n,' la: ',d);

t:=0;

max:=0;

for i:=1 to d do 

  begin

val(st[i],x,y);

t:=t+x;

if max<x then max:=x;

end;

writeln('Tong cac chu so cua ',n,' la: ',t);

writeln('Chu so lon nhat cua ',n,' la: ',max);

readln;

end.

Bình luận (0)
Linh Đan
Xem chi tiết
Võ Đức Dũng
17 tháng 9 2021 lúc 21:33

câu 1

Program Nguyen_to;

Var n,i:integer;

Function NT(n:integer):Boolean;

Var ok: Boolean;

i: integer;

Begin ok:=true;

for i:=2 to n-1 do if (n mod i)= 0 then ok:=ok and false;

if n < 2 then NT:=false else NT:=ok;

End;

Begin Write('Nhap n: ');

Readln(n); i:=n;

Repeat i:=i+1;

Until NT(i);

Write('So nguyen to nho nhat lon hon ',n, 'la: ',i);

Readln End.

Bình luận (1)
Võ Đức Dũng
17 tháng 9 2021 lúc 21:39

câu 2

uses crt;

const so: set of char=['0','1','2','3','4','5','6','7','8','9'];

var a:array[1..100] of integer;

st,b:string;

c,l,i,n,j:integer;

s, Max: integer;

begin clrscr;

write('Nhap xau:');

readln(st);

l:=length(st);

i:=1;

n:=0;

repeat if (st[i] in so) then begin b:=''

repeat b:=b+st[i];

inc(i);

until (not(st[i] in so)) or (i>l);

inc(n);

val(b,a[n],c);

end;

inc(i);

until i>l;

Max:=a[1];

for i:=2 to n do If Max<A[i] Then Max:=A[i];

Writeln('Phan tu lon nhat cua mang:', Max);

readln;

end.

Bình luận (0)
Lily Minamoto
Xem chi tiết
nguyễn an phát
26 tháng 5 2021 lúc 11:36

program so_nguyen_to;

uses crt;

var i,n:integer;

function kt(n:integer):boolean;

var i,j:integer;

begin

j:=0;

for i:=1 to n do

if n mod i=0 then inc(j);

if j=2 then kt:=true

else kt:=false;

end;

BEGIN

clrscr;

write('nhap n:');readln(n);

if kt(n) then writeln(n,' la so nguyen to')

else writeln(n,' khong phai la so nguyen to');

writeln('cac so nguyen to be hon hoac bang ',n,' la:');

for i:=1 to n do

if kt(i) then write(i:5);

writeln;

writeln('cac cap so le lien tiep la so nguyen to be hon hoac bang ',n,' la:');

for i:=1 to n do

if (i mod 2=1) and (kt(i)) and (kt(i+2)) then write(i,',',i+2);

readln;

end.

Bình luận (1)
nguyễn an phát
26 tháng 5 2021 lúc 11:39

câu c bạn viết cách ra nhé!

Bình luận (0)
Nguyễn Thái Luật
Xem chi tiết

#include <stdio.h>

int main(){

    int n;

    scanf("%d",&n);

    long t=0; int i,j;

    for (i=2; i<=n; i++){

        int c=0;

        for (j=2; j<i; j++)

            if (i%j==0) c++;

        if (c==0) t=t+i;

        }

printf("%d",t);

return 0;

}

Bình luận (0)

Bạn trình bày lại đề bài rõ hơn nha, đề đọc rất khó hiểu ấy.

Bình luận (2)
ksie
Xem chi tiết
Nguyễn Lê Phước Thịnh
20 tháng 1 2022 lúc 15:11

uses crt;

var n,i,dem,j,t:integer;

kt:boolean;

begin

clrscr;

readln(n);

t:=0;

for i:=2 to n do 

begin

kt:=true;

for j:=2 to i-1 do 

  if i mod j=0 then kt:=false;

if kt=true then 

begin

write(i:4);

t:=t+i;

end;

end;

writeln;

writeln(t);

readln;

end.

Bình luận (0)
Cuppy Cake
Xem chi tiết
Ha Cam
Xem chi tiết
Nguyễn Lê Phước Thịnh
4 tháng 5 2021 lúc 11:57

uses crt;

var a:array[1..20]of integer;

i,n,t:integer;

begin

clrscr;

write('Nhap n='); readln(n);

for i:=1 to n do 

  begin

write('A[',i,']='); readln(a[i]);

end;

for i:=1 to n do 

  write(a[i]:4);

writeln;

t:=0;

for i:=1 to n do 

 t:=t+a[i];

writeln('Tong cua day la: ',t);

for i:=1 to n do 

 if a[i]>50 then write(a[i]:4);

writeln;

for i:=1 to n do 

 if a[i]<30 then write(a[i]:4);

readln;

end.

Bình luận (0)
Lê Đăng Khôi
Xem chi tiết
Nguyễn Lê Phước Thịnh
21 tháng 2 2023 lúc 15:39

1:

uses crt;

var t,x,i,n:integer;

begin

clrscr;

t:=0;

n:=10;

for i:=1 to n do

begin

readln(x);

t:=t+x;

end;

write(t);

readln;

end.

2: 

uses crt;

var dem,x,i,n:integer;

begin

clrscr;

dem:=0;

n:=10;

for i:=1 to n do

begin

readln(x);

if x mod 2=0 then inc(dem);

end;

write(dem);

readln;

end.

Bình luận (1)
Lê Chiêu Nguyên	Vũ
4 tháng 4 2023 lúc 10:18

3

program Cacsole;
uses crt;
var M, N, i: integer;
begin
clrscr;
write ('Nhap M= '); readln(M);
write ('Nhap N= '); readln(N);
for i := M to N do

if  i mod 2 = 1 then
write (i,' ');
readln;
end.

Bình luận (1)